//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//   PACKAGE   : dcf
//   FILE      : PublisherMessage.java
//   CLASS     : PublisherMessage
//   DATE      : 2006-04-01
//   
//   DESCRIPTION
//   The PublisherMessage is the message sent from the LocatorService to a subscriber of a service that 
//   identifies the publisher.
//   
//
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//   Copyright (c) 2006 by Hal Smith
//
//   Permission is hereby granted, free of charge, to any person obtaining a copy of this source code 
//   (the "Code")to deal with the Code without restriction, including without limitation the rights to use, copy,
//   modify, merge, publish and distribute the Code, and to permit persons to whom the Code is furnished to do 
//   so, subject to the following conditions:
//
//   The above copyright notice and this permission notice shall be included in all copies or substantial 
//   portions of the Software.
//   
//
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//   VERSION HISTORY
//
//
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

package dcf;

class PublisherMessage extends Message {
	
	// The publisher of the service.
	//
	private Publisher publisher;

	
	// Constructor.
	//
	// This operations initializes the PublisherMessage to contain the supplied publisher information. The 
	// operation will log an error and throw an InitializationException if the supplied publisher is null. 
	// There are no other expceptions thrown from this operation.
	//
	public PublisherMessage(Publisher initPublisher) throws InitializationException {
	
		// If the supplied publisher is null log an error and throw an InitializationException - otherwise just
		// save the publisher locally.
		//
		if (initPublisher == null) {
			
			System.out.println("PublisherMessage.PublisherMessage(initPublisher):");
			System.out.println("   The provided publisher is null.");			
			
			throw new InitializationException();
		
		} else {
		
			publisher = initPublisher;
						
		}
	
	} // constructor

	
	// This operaiton returns the subscriber enclosed within the message. There are no exceptions thrown from
	// this operation.
	//
	public Publisher getPublisher() {
	
		return publisher;
	
	} // getPublisher()

	
	// This operation returns the name of the service the publisher provides. There are no exceptions thrown 
	// from this operation.
	//
	public String getServiceName() {
		
		return publisher.getServiceName();
	
	} // getServiceName()

}